const mongoose = require('mongoose')
const bcrypt = require('bcryptjs')

const schema = mongoose.Schema({
    username: String,
    // 密码明文应该做散列函数处理
    password: {
        type: String,
        select: false,
        set: function(val) {
            return bcrypt.hashSync(val, 10)
        }
    }
})

module.exports = mongoose.model('AdminUser', schema)